package org.bt4girls.oauth.mappy;

import org.apache.ibatis.annotations.*;
import org.bt4girls.common.model.oauth.TbPermission;
import org.springframework.stereotype.Service;

@Service
public interface TbPermissionMapper {
    int deleteByPrimaryKey(Long id);

    TbPermission selectByPrimaryKey(Long id);

    @ResultMap("BaseResultMap")
    @Select("SELECT " +
            "id,route_path,permission_name,action_id " +
            "FROM tb_permission" +
            "WHERE route_path = #{route}")
    TbPermission selectByRoutePath(@Param("route") String route);


    @ResultMap("BaseResultMap")
    @Select("SELECT " +
            "id,route_path,permission_name,action_id " +
            "FROM tb_permission" +
            "WHERE action_id = #{actionId}")
    TbPermission selectByActionId(@Param("actionId") String actionId);


    @Insert("INSERT INTO tb_permission(`route_path`, `action_id`, `permission_name`) " +
            "VALUES (#{}, #{}, #{})")
    int insertPermission(@Param("route") String route, @Param("actionId") String actionId, @Param("name") String name);

}